package com.example.demo.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JSONController {
    @CrossOrigin(origins = "*", allowedHeaders = "*")
    @GetMapping("/json")
    public Map<String,List<Map<String,String>>> getData(){
        List<Map<String,String>> list = new ArrayList<>();
        Map<String,List<Map<String,String>>> data = new HashMap<>();
        Map<String, String> data1 = new HashMap<>();
        data1.put("id", "0");
        data1.put("title", "肾虚");
        data1.put("subtitle", "shenxu");
        data1.put("avatar", "https://randomuser.me/api/portraits/women/7.jpg");
        list.add(data1);
        Map<String, String> data2 = new HashMap<>();
        data2.put("id", "1");
        data2.put("title", "肾虚了吗");
        data2.put("subtitle", "shenbuxu");
        data2.put("avatar", "https://randomuser.me/api/portraits/women/8.jpg");
        list.add(data2);
        Map<String, String> data3 = new HashMap<>();
        data3.put("id", "2");
        data3.put("title", "枸杞");
        data3.put("subtitle", "jiushishenxu");
        data3.put("avatar", "https://randomuser.me/api/portraits/women/6.jpg");
        list.add(data3);
        Map<String, String> data4 = new HashMap<>();
        data4.put("id", "3");
        data4.put("title", "枸杞");
        data4.put("subtitle", "jiushishenxu");
        data4.put("avatar", "https://randomuser.me/api/portraits/women/5.jpg");
        list.add(data4);
        Map<String, String> data5 = new HashMap<>();
        data5.put("id", "4");
        data5.put("title", "枸杞");
        data5.put("subtitle", "jiushishenxu");
        data5.put("avatar", "https://randomuser.me/api/portraits/women/3.jpg");
        list.add(data5);
        data.put("title", list);
        return data;
    }
}
